<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/wap/css/statistics.css">
    <title>数据动态增长统计-{$webseting.web_title}</title>
</head>
<body>
    <div class="wrapper">
        <div>
            <style>.plugin-countdown{max-width:640px;margin:0 auto;}</style>
            <div class="plugin-countdown">
                <div class="countdown-wrap">
                    <p class="txt"><em>{$webseting.web_title}实时数据统计</em></p>
                    <div class="counter" id="divdown1">
                        <span>-</span>
                        <span>-</span> 天
                        <span>-</span>
                        <span>-</span> 时
                        <span>-</span>
                        <span>-</span> 分
                        <span>-</span>
                        <span>-</span> 秒
                        <span class="msec">1</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="tj">
            <div><label>注册会员</label><span class="user">{$data.user}</span>/人</div>
            <div><label>产品</label><span class="shop">{$data.shop}</span>个</div>
        </div>
        <div class="list">
            <h3>实时数据增长</h3>
            <ul class="data_list">
                <li class="list-c add_data">
                    <div>类别</div>
                    <div>日期</div>
                </li>

                <volist name="list" id="vo">
                <li>
                    <div>{$vo.text}</div>
                    <div>{$vo.time}</div>
                </li>
               </volist>


            </ul>
        </div>
<div ></div>
    </div>
<script src="__PUBLIC__/bootstrap/vendor/jquery/jquery.min.js"></script>    
 <script type="text/javascript">
 $(function(){
  set_num();//数量
  set_data()//数据
 });
 function set_num(){
    // max - 期望的最大值
// min - 期望的最小值 
//parseInt(Math.random()*(max-min+1)+min,10);
//Math.floor(Math.random()*(max-min+1)+min);
// 15  - 60分钟涨一次
     var num2=parseInt(Math.random()*(3600-900+1)+900,10);
    setTimeout('set_num2()',num2*1000);
 }
  function set_num2(){
    // max - 期望的最大值
// min - 期望的最小值 
//parseInt(Math.random()*(max-min+1)+min,10);
//Math.floor(Math.random()*(max-min+1)+min);
    var num=parseInt(Math.random()*(100+1),10);
     var num2=parseInt(Math.random()*(100+1),10);
    if(num>10){
        //用户
        get_more(1);
    }else{
        //商户
         get_more(0);
    }
    setTimeout('set_num2()',num2*1000);
 }
  function set_data(){
  // 30-60 秒刷新一次
     var num2=parseInt(Math.random()*(60-30+1)+30,10);
    setTimeout('set_data2()',num2*1000);
 }
   function set_data2(){
   get_data();
     var num2=parseInt(Math.random()*(9+1),10);
    setTimeout('set_data2()',num2*1000);
 }
 function get_data(){
           $.ajax({ 
            url: "{:U('wap/index/get_data')}",
            type:'get',
            //data: {type:type},
            dataType: 'json',
            success: function(data){
              if(data){
                  var str ='<li><div>'+data.text+'</div><div>'+data.time+'</div></li>';
                  $('.add_data').after(str);
                  $('.data_list li:last').remove();
                }
            }
        });
 
}
 function get_more(type){
           $.ajax({ 
            url: "{:U('wap/index/set_num')}",
            type:'get',
            data: {type:type},
            dataType: 'json',
            success: function(data){
              if(data){
                  if(type==1){
                    //用户
                    $('.user').html(data);
                  }else{
                    //商户
                    $('.shop').html(data);
                  }
                }
            }
        });
 
}
var interval = 100; 
function ShowCountDown(year,month,day,divname) 
{ 
var now = new Date(); 
var endDate = new Date(year, month-1, day); 
var leftTime=now.getTime()-endDate.getTime(); 
var leftsecond = parseInt(leftTime/1000); 
//var day1=parseInt(leftsecond/(24*60*60*6)); 
var day1=Math.floor(leftsecond/(60*60*24)); 
var hour=Math.floor((leftsecond-day1*24*60*60)/3600); 
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60); 
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
 var nS = Math.floor((leftTime-day1*24*60*60*1000-hour*3600*1000-minute*60*1000-second*1000)/10);  //毫秒
var cc = document.getElementById(divname); 
var day1_1=0;
var day1_2=0;
if(day1<10){
day1_1=0;
day1_2=day1;
}else{
  day1_1=parseInt(day1/10);
  day1_2=day1%10;
}
var hour_1=0;
var hour_2=0;
if(hour<10){
hour_1=0;
hour_2=hour;
}else{
  hour_1=parseInt(hour/10);
  hour_2=hour%10;
}

var minute_1=0;
var minute_2=0;
if(minute<10){
minute_1=0;
minute_2=minute;
}else{
  minute_1=parseInt(minute/10);
  minute_2=minute%10;
}
var second_1=0;
var second_2=0;
if(second<10){
second_1=0;
second_2=second;
}else{
  second_1=parseInt(second/10);
  second_2=second%10;
}
if(nS<10){
    nS="0"+nS;
}
cc.innerHTML = '<span>'+day1_1+'</span>'+
                 '       <span>'+day1_2+'</span> 天'+
                  '      <span>'+hour_1+'</span>'+
                   '     <span>'+hour_2+'</span> 时'+
                    '    <span>'+minute_1+'</span>'+
                     '   <span>'+minute_2+'</span> 分'+
                     '   <span>'+second_1+'</span>'+
                      '  <span>'+second_2+'</span> 秒'+
                      '  <span class="msec">'+nS+'</span>'; 
} 
window.setInterval(function(){ShowCountDown(2015,8,1,'divdown1');}, interval); 
 </script>   
</body>
</html>